<template>
  <div style="position:relative">
  <div class="pagetitle ">{{title}}-{{name}}</div>
     <div style="margin-top:0px;position: relative;background:#fff">
  <v-container>
    <v-row gutters>
      <v-col
        md="4" cols="12"
        v-for="(item) of articleList"
        :key="item.id"
        >
    <v-card
        class="mx-auto overflow-auto rounded-0 tag-cloud  "
        max-width="350"
      >
        <router-link :to="'/articles/' + item.id">
        <v-img
          class="white--text align-end"
          height="200px"
          :src="item.articleCoverSm"
        >
        </v-img>

        <v-card-title ><div  style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;">{{item.articleTitle}}</div></v-card-title>
                </router-link>
        <v-card-text class="text--primary">
          <div  style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;">{{item.articleContent}}</div>
        </v-card-text>

        <v-card-actions>
          <v-icon>mdi-send</v-icon>
          <v-btn
            color="grey"
            text
          >
            {{item.createTime}}
          </v-btn>
        </v-card-actions>
      </v-card>
      </v-col>
    </v-row>
  </v-container>
  </div>
  </div>
</template>

<script>
export default {
  created() {
    const path = this.$route.path;
    if (path.indexOf("/categories") != -1) {
      this.title = "分类";
    } else {
      this.title = "标签";
    }
    this.infiniteHandler()
  },
  data: function() {
    return {
      current: 1,
      size: 10,
      articleList: [],
      name: "",
      title: ""
    };
  },
  methods: {
    infiniteHandler() {
      this.axios
        .get("/articles/condition", {
          params: {
            categoryId: this.$route.params.categoryId,
            tagId: this.$route.params.tagId,
            current: this.current
          }
        })
        .then(({ data }) => {
          if (data.data.name) {
            this.name = data.data.name;
          data.data.articlePreviewDTOList.forEach(item=>{
            item.createTime =item.createTime.substring(0,10)
          })
            document.title = this.title + " - " + this.name;
          }
          if (data.data.articlePreviewDTOList.length) {
            this.current++;
            this.articleList.push(...data.data.articlePreviewDTOList);
          } 
        });
    }
  },
  computed: {
  }
};
</script>

<style scoped>
@media (min-width: 760px) {
  .article-list-wrapper {
    max-width: 1106px;
    margin: 370px auto 1rem auto;
  }
  .article-item-card:hover {
    transition: all 0.3s;
    box-shadow: 0 4px 12px 12px rgba(7, 17, 27, 0.15);
  }
  .article-item-card:not(:hover) {
    transition: all 0.3s;
  }
  .article-item-card:hover .on-hover {
    transition: all 0.6s;
    transform: scale(1.1);
  }
  .article-item-card:not(:hover) .on-hover {
    transition: all 0.6s;
  }
  .article-item-info {
    line-height: 1.7;
    padding: 15px 15px 12px 18px;
    font-size: 15px;
  }
}
@media (max-width: 759px) {
  .article-list-wrapper {
    margin-top: 230px;
    padding: 0 12px;
  }
  .article-item-info {
    line-height: 1.7;
    padding: 15px 15px 12px 18px;
  }
}
.article-item-card {
  border-radius: 8px !important;
  box-shadow: 0 4px 8px 6px rgba(7, 17, 27, 0.06);
}
.article-item-card a {
  transition: all 0.3s;
}
.article-item-cover {
  height: 220px;
  overflow: hidden;
}
.article-item-card a:hover {
  color: #8e8cd8;
}
.tag-wrapper {
  padding: 10px 15px 10px 18px;
}
.tag-wrapper a {
  color: #fff !important;
}
.tag-btn {
  display: inline-block;
  font-size: 0.725rem;
  line-height: 22px;
  height: 22px;
  border-radius: 10px;
  padding: 0 12px !important;
  background: linear-gradient(to right, #bf4643 0%, #6c9d8f 100%);
  opacity: 0.6;
  margin-right: 0.5rem;
}
</style>
